package elven.d.rabbitmq.server.util;

import com.rabbitmq.client.ConnectionFactory;

public class RabbitMQConnectionFactory {

	private RabbitMQConnectionFactory(){};
	
	private volatile static ConnectionFactory connectionFactory;
	private static final String host = "192.168.5.130";
	private static final String username = "admin";
	private static final String password = "admin";
	
	public static ConnectionFactory getConnectionFactory(){
		synchronized (RabbitMQConnectionFactory.class) {
			if(connectionFactory == null){
				connectionFactory = new ConnectionFactory();
				//设置主机地址和端口号
				connectionFactory.setHost(host);
				connectionFactory.setUsername(username);
				connectionFactory.setPassword(password);
			}
			return connectionFactory;
		}
	}
	
}
